package com.cjg.Class;

public class demo02 {
    public static void main(String[] args) throws ClassNotFoundException {
        Msg s = new s();
        System.out.println(s.name);

        //方法一
        Class c1 = s.getClass();
        //方法二
        Class c2 = Class.forName("com.cjg.Cla" +
                "ss.s");
        //方法三
        Class c3 = s.class;
        System.out.println(c2.hashCode());
        System.out.println(c3.hashCode());
        //方法四  内置类型的包装类由tyoe属性
        Class<Integer> type = Integer.TYPE;
        System.out.println(type);
        //方法五 从父类方法获得
        Class superclass = c1.getSuperclass();
        System.out.println(superclass);
    }
}
class Msg{
    public String name;

    public Msg() {
    }

    public Msg(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Msg{" +
                "name='" + name + '\'' +
                '}';
    }
}
class s extends Msg{
    public s() {
        this.name="学生";
    }
}
class t extends Msg{
    public t() {
        this.name="老师";
    }
}